package com.siyougame.business.dal.mysql.user;

import java.util.*;

import com.siyougame.common.pojo.PageResult;
import com.siyougame.mybatis.mybatis.core.query.LambdaQueryWrapperX;
import com.siyougame.mybatis.mybatis.core.mapper.BaseMapperX;
import com.siyougame.business.dal.dataobject.user.WxUserDO;
import org.apache.ibatis.annotations.Mapper;
import com.siyougame.business.controller.admin.user.vo.*;

/**
 * 微信用户 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface WxUserMapper extends BaseMapperX<WxUserDO> {

    default PageResult<WxUserDO> selectPage(WxUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WxUserDO>()
                .likeIfPresent(WxUserDO::getName, reqVO.getName())
                .eqIfPresent(WxUserDO::getToken, reqVO.getToken())
                .betweenIfPresent(WxUserDO::getExpiresTime, reqVO.getBeginExpiresTime(), reqVO.getEndExpiresTime())

                .likeIfPresent(WxUserDO::getNickname, reqVO.getNickname())

                .eqIfPresent(WxUserDO::getStatus, reqVO.getStatus())
                .eqIfPresent(WxUserDO::getRemark, reqVO.getRemark())
                .eqIfPresent(WxUserDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(WxUserDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(WxUserDO::getId));
    }

    default List<WxUserDO> selectList(WxUserExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<WxUserDO>()
                .likeIfPresent(WxUserDO::getName, reqVO.getName())
                .eqIfPresent(WxUserDO::getToken, reqVO.getToken())
                .betweenIfPresent(WxUserDO::getExpiresTime, reqVO.getBeginExpiresTime(), reqVO.getEndExpiresTime())

                .likeIfPresent(WxUserDO::getNickname, reqVO.getNickname())

                .eqIfPresent(WxUserDO::getStatus, reqVO.getStatus())
                .eqIfPresent(WxUserDO::getRemark, reqVO.getRemark())
                .eqIfPresent(WxUserDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(WxUserDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(WxUserDO::getId));
    }

}